
from pylab import *
from rapameters import *
from oscillator_hash import *
from copy import *
from time import *
from raptools import *
from wave import Wave
from random import *;

TIME                = 100;
DT                  = 0.1;
AMP_MAX             = 200


#run rap6.py 
#               [tau, rp,   rm, qp, qm, m,  n,  k]


#run6
target  = Wave(float(16),1.0/float(24),TIME,DT)
rarray = [9.2368511295552782, 1.9767713195111938, 1.6664059123907351, 0.53661906803386461, 0.99645082014860609, 2.85751441601652, 6.1476674504460336, 2.2114851186039757]


#run1
#target  = Wave(float(8),1.0/float(12),TIME,DT)
#rarray= [4.2627250576775024, 2.9862212038326659, 2.7310056297084717, 0.73907736245346678, 1.1340495860008941, 0.80173212622825751, 6.4285210364760648, 3.8562676775185789]

#run7
target  = Wave(float(16),1.0/float(24),TIME,DT)
rarray = [8.4488948540555491, 2.0273043988333539, 1.6098517690042096, 0.66204133845355029, 0.9276339434360743, 3.0, 3.0555585127435707, 0.087618911766850993]


#runx
#target = Wave(float(10), 1.0/float(10), TIME, DT)
#rarray = [3.913232216497704, 2.5345697564184304, 1.9638378342265752, 1.8626551123079373, 0.8040735740129936, 2.266896521490775, 2.0, 1.8314082935540663]


start   = Oscillator(rarray,TIME,DT,3, AMP_MAX)
spt = start.get_times();
spv = start.get_vals();
spm = target.get_vals();



print "----------------------------------------------------------"
print 'OSCILLATOR : CURRENT BEST', id(start), ' (BLUE)'
print "----------------------------------------------------------"
print 'amp: ',start.get_amp();
print 'frq: ', start.get_frq();
#print 'wl: ', start.get_wl();
print 'time up: ',start.get_tim_up();
print 'time down: ',start.get_tim_down();
print 'parameters', start.get_rapams();
print ""
print start


plot(spt,spv,'k-')
plot(spt,spm,'r-', linestyle='dashed')
xticks(range(0,TIME+1,20))
yticks(range(0,int(start.get_amp())+1,1))
xlabel('Time (h)')
ylabel('Protein (full line) / mRNA (dashed line) concentration')
#ylabel('Protein concentration (full line) / Sine wave (dashed line)')
#show()
savefig(sys.argv[1], format='png')
